Developer Documentation
PATHJava Developer Documentation > Mac OS Runtime for Java > JManager > Programming With JManager


Utility Functions


JMGetVersion

Returns the version of JManager available on the host computer.

UInt32 JMGetVersion (void);
function result
A version code. This value is similar to the value of the kJMVersion constant.

DISCUSSION

A version of JManager older than the one your embedding application compiled against may not have the same functionality; you can use JMGetVersion and compare the result against kJMVersion to avoid calling nonexisting functions.


JMGetMRJRuntimeVersion

Returns the version of Mac OS Runtime for Java (MRJ) installed on the host computer.

UInt32 JMGetMRJRuntimeVersion ();

function result The version of MRJ currently installed. This four-byte value has the same form as a NumVersion structure, which is the first four bytes of a resource of type 'vers' .


JMFSSToURL

Converts a Mac OS file system specification record ( FSSpec ) into a Uniform Resource Locator (URL) string.

Handle JMFSSToURL   (JMSessionRef session,
                     const FSSpec* spec);
session
The current session.
spec
A pointer to a file system specification record.
function result
A handle containing a URL string in the form file://xxxx . If the file cannot be found, the function returns null .

DISCUSSION

The JMFSSToURL function resolves the path of the file represented by the file system specification record and returns this information as a URL string. The handle returned points to a null-terminated string. Your application is responsible for calling the Mac OS Toolbox function DisposeHandle to release the allocated handle.

SEE ALSO

The JMURLToFSS function.


JMURLToFSS

Converts a Uniform Resource Locator (URL) into a Mac OS file system specification record ( FSSpec ).

OSStatus JMURLToFSS (JMSessionRef session,
                     const JMTextRef urlString,
                     FSSpec* spec);
session
The current session.
urlString
The URL string to be converted, as a text object.
spec
A pointer to a file system specification record. Upon return, spec points to the converted URL.
function result
A result code; see JManager Result Codes.

DISCUSSION

The URL string must follow the format file:///disk/dir1/.../dirN/file . Other formats cause the function to return the result code paramErr .

SEE ALSO

The JMFSSToURL function.

Executing Java Applications.


JMAddToClassPath

Adds a directory, zip file, or Java archive (JAR) file to the class path.

OSStatus JMAddToClassPath (
                     JMSessionRef session,
                     const FSSpec* spec);
session
The current session.
spec
A pointer to a file system specification record.
function result
A result code; see JManager Result Codes.

DISCUSSION

The JMAddToClassPath function adds an additional file to the Java class definition search path by appending a Mac OS file system specification record (FSSpec) to the class path of the current session. You can add any number of files to the class path. The FSSpec value can indicate an uncompressed zip file or a directory. A directory is considered to be the root of a class hierarchy.

Note

If you want to prepend a file to the class path, you should add it directly to the MRJClasses folder.

SEE ALSO

Executing Java Applications.


JMGetCurrentEnv

Returns the current JNIEnv data structure.

struct JNIEnv* JMGetCurrentEnv (JMSessionRef session);
session
The current session.
function result
A pointer to the JNIEnv data structure.

DISCUSSION

The JMGetCurrentEnv function allows you to access the current Java Native Interface (JNI) structure. Once you have the JNIEnv structure, you can call JNI functions. The data structure JNIEnv is defined in the header file JNI.h .

You can find documentation for the Java Native Interface at the Web site

http://java.sun.com/

SEE ALSO

Executing Java Applications.


JMGetJRIRuntimeInstance

Returns the current JRIRuntimeInstance data structure.

struct JRIRuntimeInstance* JMGetJRIRuntimeInstance (
                     JMSessionRef session);
session
The current session.
function result
A pointer to the JRIRuntimeInstance data structure.

DISCUSSION

The JMGetJRIRuntimeInstance function allows you to get information about the current Java Runtime Interface (JRI) structure. The data structure JRIRuntimeInstance is defined in the header file JRI.h .

Note

Unless you have a particular reason to access the Java Runtime Interface, you should access the Java Native Interface, which provides similar functionality, instead.

You can find documentation for the Java Runtime Interface at the Web site

http://developer.netscape.com/


JMGetCurrentJRIEnv

Returns the current JRIEnv data structure.

struct JRIEnv* JMGetCurrentJRIEnv (JMSessionRef session);
session
The current session.
function result
A pointer to the JRIEnv data structure.

DISCUSSION

The JMGetCurrentJRIEnv function allows you to obtain the current Java Runtime Interface (JRI) structure. Once you have the JRIEnv structure, you can call JRI functions. The data structure JRIEnv is defined in the header file JRI.h .

Note

Unless you have a particular reason to access the Java Runtime Interface, you should access the Java Native Interface, which provides similar functionality, instead.

You can find documentation for the Java Runtime Interface at the Web site

http://developer.netscape.com/


JMJRIRefToJNIObject

Converts a JRI-based jref to a JNI-based jobject .

jobject JMJRIRefToJNIObject (
                     JMSessionRef session,
                     JNIEnv* env,
                     jref jriRef);
session
The current session.
env
The current JNIEnv data structure.
jriRef
The jref to convert.
function result
A pointer to the jobject object.

DISCUSSION

If you want to use jref object references with the Java Native Interface (JNI), you must convert them to jobject references using JMJRIRefToJNIObject . Note that you must have a pointer to the current JNIEnv data structure before calling this function.

SEE ALSO

The JMGetCurrentEnv function.


JMJNIObjectToJRIRef

Converts a JNI-based jobject to a JRI-based jref .

jref JMJNIObjectToJRIRef (
                     JMSessionRef session,
                     JNIEnv* env,
                     jobject jniObject);
session
The current session.
env
The current JNIEnv data structure.
jniObject
The jObject to convert.
function result
A pointer to the jref object.

DISCUSSION

If you want to use jobject object references with the Java Runtime Interface (JRI), you must convert them to jref references using JMJNIObjectToJRIRef. Note that you must have a pointer to the current JNIEnv data structure before calling this function.

SEE ALSO

The JMGetCurrentEnv function.


JMJNIToAWTContext

Maps a JNI-based JNIEnv to the owning AWT context, if one exists.

JMAWTContextRef JMJNIToAWTContext (
                     JMSessionRef session,
                     JNIEnv* env);
session
The current session.
env
The current JNIEnv data structure.
jniObject
The jObject to convert.
function result
A pointer to the jref object.

DISCUSSION

Note that you must have a pointer to the current JNIEnv data structure before calling this function.

SEE ALSO

The JMGetCurrentEnv function.


JMRegisterLibrary

Adds the connection ID of a prepared fragment to the list of shared libraries used when searching for JNI (and JRI) native methods.

Boolean JMRegisterLibrary (
                     JMSessionRef session,
                     ConstStr63Param libraryName,
                     CFragConnectionID connID,
                     Boolean javaShouldClose);
session
The current session.
libraryName
The name passed to System.loadLibrary that would result in the use of the connection ID. Note that this is the name of the actual fragment,which may differ from the name of the file containing the fragment.
connID
The connection ID of the instantiated fragment.
javaShouldClose
A Boolean value. If true, JManager will remove the instantiated fragment when the Java session ends (if no other programs require it).
function result
Returns false if a library with the same name is already registered; no action was taken. Otherwise returns true.

DESCRIPTION

The Java method System.loadLibrary does not reuse existing connections to shared libraries if they were instantiated by programs outside the Java environment. Instead, it creates an additional private copy of the shared library fragment for its own use. Doing so means that multiple instances of a library's data/TOC section may exist in memory. To override this problem, you can register an instantiated library with JManager using JMRegisterLibrary . Then, whenever calls to native methods are made using the Java Native Interface (JNI) or Java Runtime Interface (JRI), JManager will search the list of registered libraries before attempting to instantiate one.

SEE ALSO

For more information about shared library fragments, connection IDs, and the fragment preparation process, see Mac OS Runtime Architectures .


© 1998 Apple Computer, Inc. — (Last Updated 3 Dec 98)